package com.sense.common.utils;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: jiangyong
 * @Date: 2025/10/28/10:35
 * @Description:
 */
public class FileOper {

    public static List<String> listFileNames(String path) {
        try {
            return Files.list(Paths.get(path))
                    .filter(Files::isRegularFile)
                    .map(filePath -> filePath.getFileName().toString())
                    .collect(Collectors.toList());
        } catch (IOException e) {
            // 建议添加适当的异常处理
            throw new RuntimeException("Failed to list files in directory: " + path, e);
        }
    }
}
